package com.zemb.flxwear.TaskQueue;

import android.app.Service;
import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;

import java.util.List;

public class TaskService extends Service {
    protected TaskQueue taskQueue;
    protected TaskBinder taskBinder;


    public TaskService() {
    }

    @Override
    public void onCreate() {
        super.onCreate();
        taskQueue = new TaskQueue();
        taskBinder = new TaskBinder();
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {


        return super.onStartCommand(intent, flags, startId);
    }

    @Override
    public IBinder onBind(Intent intent) {
        // TODO: Return the communication channel to the service.

        return taskBinder;
    }





    public void setTaskQueue(List<BaseTask> taskList) {
        taskQueue.clear();
        for (BaseTask task : taskList) {
            taskQueue.addTask(task);
        }
    }


    public class TaskBinder extends Binder {
        public TaskService getService() {
            return TaskService.this;
        }
        public void AddTask(BaseTask task) {
            taskQueue.addTask(task);
        }

        public BaseTask getCurrentTask() {
            return taskQueue.getCurrentTask();
        }



        public void clear() {
            taskQueue.clear();
        }
    }
}